/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controleur.TableModel;

import Modele.TypeIncident;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author 20cent
 */
public class TypeIncTableModel extends AbstractTableModel {

    private ArrayList<TypeIncident> types;
    public static final String[] COLONNES = {"ID",
        "Nom",
        "Description",
        "Matériel"};

    public TypeIncTableModel(ArrayList<TypeIncident> types) {
        this.types = types;
    }

    public void setTypesInc(ArrayList<TypeIncident> types) {
        this.types = types;
        fireTableDataChanged();
    }

    @Override
    public int getRowCount() {
        return types.size();
    }

    @Override
    public int getColumnCount() {
        return COLONNES.length;
    }

    @Override
    public String getColumnName(int column) {
        return COLONNES[column];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        TypeIncident type = types.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return type.getMId();
            case 1:
                return type.getTypeincNom();
            case 2:
                return type.getMDescription();
            case 3:
                return type.getTypeincOutils();
            default:
                return null;
        }
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        switch (columnIndex) {
            case 0:
                return int.class;
            default:
                return String.class;
        }
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }
}
